package com.bbva.kyfb.kyfbjpatlbh.dominiotlbh;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Ttlsbcab.
 */
@Entity
@Table(name = "TTLSBCAB",schema = "TLSB")
@Configurable
@RooJavaBean
@RooToString
@RooEntity(identifierType = TtlsbcabPK.class, versionField = "",  persistenceUnit="persistenceUnitTLBH",table = "TTLSBCAB", schema = "TLSB")
@PersistenceContext(unitName="persistenceUnitTLBH")
@RooDbManaged(automaticallyDelete = true)
public class Ttlsbcab {

	/** The cod cdnitr. */
	@Column(name = "COD_CDNITR",columnDefinition = "CHAR", length = 10)
    private String codCdnitr;

	/** The cod sufprese. */
	@Column(name = "COD_SUFPRESE",columnDefinition = "CHAR", length = 3)
    private String codSufprese;

	/** The cod diisoalf. */
	@Column(name = "COD_DIISOALF",columnDefinition = "CHAR", length = 3)
    private String codDiisoalf;

	/** The fec procesca. */
	@Column(name = "FEC_PROCESCA",columnDefinition = "CHAR", length = 8)
    private String fecProcesca;

	/** The des reficher. */
	@Column(name = "DES_REFICHER",columnDefinition = "CHAR", length = 30)
    private String desReficher;

	/** The des nomfich. */
	@Column(name = "DES_NOMFICH",columnDefinition = "CHAR", length = 20)
    private String desNomfich;

	/** The xsn medcreac. */
	@Column(name = "XSN_MEDCREAC",columnDefinition = "CHAR", length=1)
    private Character xsnMedcreac;

	/** The xsn modcreac. */
	@Column(name = "XSN_MODCREAC",columnDefinition = "CHAR", length=1)
    private Character xsnModcreac;

	/** The fec borrcash. */
	@Column(name = "FEC_BORRCASH",columnDefinition = "CHAR", length = 8)
    private String fecBorrcash;

	/** The fec estacash. */
	@Column(name = "FEC_ESTACASH",columnDefinition = "CHAR", length = 8)
    private String fecEstacash;

	/** The aud fmodific. */
	@Column(name = "AUD_FMODIFIC",columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE )
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	/** The aud usuario. */
	@Column(name = "AUD_USUARIO", columnDefinition = "CHAR",length = 8)
    @NotNull
    private String audUsuario;

	/** The qty totimp. */
	@Column(name = "QTY_TOTIMP",columnDefinition = "DECIMAL", precision = 17, scale = 2)
    private BigDecimal qtyTotimp;

	/** The qnu totregis. */
	@Column(name = "QNU_TOTREGIS")
    private Integer qnuTotregis;

	/** The xsn formpago. */
	@Column(name = "XSN_FORMPAGO",columnDefinition = "CHAR", length=1)
    private Character xsnFormpago;

	/** The cod estacash. */
	@Column(name = "COD_ESTACASH",columnDefinition = "CHAR", length = 3)
    private String codEstacash;

	/** The xsn multirem. */
	@Column(name = "XSN_MULTIREM",columnDefinition = "CHAR", length=1)
    private Character xsnMultirem;

	/** The cod tip pagx. */
	@Column(name = "COD_TIP_PAGX",columnDefinition = "CHAR", length = 2)
    private String codTipPagx;

	/**
	 * Gets the cod cdnitr.
	 *
	 * @return the cod cdnitr
	 */
	public String getCodCdnitr() {
        return this.codCdnitr;
    }

	/**
	 * Sets the cod cdnitr.
	 *
	 * @param codCdnitr the new cod cdnitr
	 */
	public void setCodCdnitr(String codCdnitr) {
        this.codCdnitr = codCdnitr;
    }

	/**
	 * Gets the cod sufprese.
	 *
	 * @return the cod sufprese
	 */
	public String getCodSufprese() {
        return this.codSufprese;
    }

	/**
	 * Sets the cod sufprese.
	 *
	 * @param codSufprese the new cod sufprese
	 */
	public void setCodSufprese(String codSufprese) {
        this.codSufprese = codSufprese;
    }

	/**
	 * Gets the cod diisoalf.
	 *
	 * @return the cod diisoalf
	 */
	public String getCodDiisoalf() {
        return this.codDiisoalf;
    }

	/**
	 * Sets the cod diisoalf.
	 *
	 * @param codDiisoalf the new cod diisoalf
	 */
	public void setCodDiisoalf(String codDiisoalf) {
        this.codDiisoalf = codDiisoalf;
    }

	/**
	 * Gets the fec procesca.
	 *
	 * @return the fec procesca
	 */
	public String getFecProcesca() {
        return this.fecProcesca;
    }

	/**
	 * Sets the fec procesca.
	 *
	 * @param fecProcesca the new fec procesca
	 */
	public void setFecProcesca(String fecProcesca) {
        this.fecProcesca = fecProcesca;
    }

	/**
	 * Gets the des reficher.
	 *
	 * @return the des reficher
	 */
	public String getDesReficher() {
        return this.desReficher;
    }

	/**
	 * Sets the des reficher.
	 *
	 * @param desReficher the new des reficher
	 */
	public void setDesReficher(String desReficher) {
        this.desReficher = desReficher;
    }

	/**
	 * Gets the des nomfich.
	 *
	 * @return the des nomfich
	 */
	public String getDesNomfich() {
        return this.desNomfich;
    }

	/**
	 * Sets the des nomfich.
	 *
	 * @param desNomfich the new des nomfich
	 */
	public void setDesNomfich(String desNomfich) {
        this.desNomfich = desNomfich;
    }

	/**
	 * Gets the xsn medcreac.
	 *
	 * @return the xsn medcreac
	 */
	public Character getXsnMedcreac() {
        return this.xsnMedcreac;
    }

	/**
	 * Sets the xsn medcreac.
	 *
	 * @param xsnMedcreac the new xsn medcreac
	 */
	public void setXsnMedcreac(Character xsnMedcreac) {
        this.xsnMedcreac = xsnMedcreac;
    }

	/**
	 * Gets the xsn modcreac.
	 *
	 * @return the xsn modcreac
	 */
	public Character getXsnModcreac() {
        return this.xsnModcreac;
    }

	/**
	 * Sets the xsn modcreac.
	 *
	 * @param xsnModcreac the new xsn modcreac
	 */
	public void setXsnModcreac(Character xsnModcreac) {
        this.xsnModcreac = xsnModcreac;
    }

	/**
	 * Gets the fec borrcash.
	 *
	 * @return the fec borrcash
	 */
	public String getFecBorrcash() {
        return this.fecBorrcash;
    }

	/**
	 * Sets the fec borrcash.
	 *
	 * @param fecBorrcash the new fec borrcash
	 */
	public void setFecBorrcash(String fecBorrcash) {
        this.fecBorrcash = fecBorrcash;
    }

	/**
	 * Gets the fec estacash.
	 *
	 * @return the fec estacash
	 */
	public String getFecEstacash() {
        return this.fecEstacash;
    }

	/**
	 * Sets the fec estacash.
	 *
	 * @param fecEstacash the new fec estacash
	 */
	public void setFecEstacash(String fecEstacash) {
        this.fecEstacash = fecEstacash;
    }

	/**
	 * Gets the aud fmodific.
	 *
	 * @return the aud fmodific
	 */
	public Date getAudFmodific() {
        return this.audFmodific;
    }

	/**
	 * Sets the aud fmodific.
	 *
	 * @param audFmodific the new aud fmodific
	 */
	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }

	/**
	 * Gets the aud usuario.
	 *
	 * @return the aud usuario
	 */
	public String getAudUsuario() {
        return this.audUsuario;
    }

	/**
	 * Sets the aud usuario.
	 *
	 * @param audUsuario the new aud usuario
	 */
	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	/**
	 * Gets the qty totimp.
	 *
	 * @return the qty totimp
	 */
	public BigDecimal getQtyTotimp() {
        return this.qtyTotimp;
    }

	/**
	 * Sets the qty totimp.
	 *
	 * @param qtyTotimp the new qty totimp
	 */
	public void setQtyTotimp(BigDecimal qtyTotimp) {
        this.qtyTotimp = qtyTotimp;
    }

	/**
	 * Gets the qnu totregis.
	 *
	 * @return the qnu totregis
	 */
	public Integer getQnuTotregis() {
        return this.qnuTotregis;
    }

	/**
	 * Sets the qnu totregis.
	 *
	 * @param qnuTotregis the new qnu totregis
	 */
	public void setQnuTotregis(Integer qnuTotregis) {
        this.qnuTotregis = qnuTotregis;
    }

	/**
	 * Gets the xsn formpago.
	 *
	 * @return the xsn formpago
	 */
	public Character getXsnFormpago() {
        return this.xsnFormpago;
    }

	/**
	 * Sets the xsn formpago.
	 *
	 * @param xsnFormpago the new xsn formpago
	 */
	public void setXsnFormpago(Character xsnFormpago) {
        this.xsnFormpago = xsnFormpago;
    }

	/**
	 * Gets the cod estacash.
	 *
	 * @return the cod estacash
	 */
	public String getCodEstacash() {
        return this.codEstacash;
    }

	/**
	 * Sets the cod estacash.
	 *
	 * @param codEstacash the new cod estacash
	 */
	public void setCodEstacash(String codEstacash) {
        this.codEstacash = codEstacash;
    }

	/**
	 * Gets the xsn multirem.
	 *
	 * @return the xsn multirem
	 */
	public Character getXsnMultirem() {
        return this.xsnMultirem;
    }

	/**
	 * Sets the xsn multirem.
	 *
	 * @param xsnMultirem the new xsn multirem
	 */
	public void setXsnMultirem(Character xsnMultirem) {
        this.xsnMultirem = xsnMultirem;
    }

	/**
	 * Gets the cod tip pagx.
	 *
	 * @return the cod tip pagx
	 */
	public String getCodTipPagx() {
        return this.codTipPagx;
    }

	/**
	 * Sets the cod tip pagx.
	 *
	 * @param codTipPagx the new cod tip pagx
	 */
	public void setCodTipPagx(String codTipPagx) {
        this.codTipPagx = codTipPagx;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");
        sb.append("CodCdnitr: ").append(getCodCdnitr()).append(", ");
        sb.append("CodDiisoalf: ").append(getCodDiisoalf()).append(", ");
        sb.append("CodEstacash: ").append(getCodEstacash()).append(", ");
        sb.append("CodSufprese: ").append(getCodSufprese()).append(", ");
        sb.append("CodTipPagx: ").append(getCodTipPagx()).append(", ");
        sb.append("DesNomfich: ").append(getDesNomfich()).append(", ");
        sb.append("DesReficher: ").append(getDesReficher()).append(", ");
        sb.append("FecBorrcash: ").append(getFecBorrcash()).append(", ");
        sb.append("FecEstacash: ").append(getFecEstacash()).append(", ");
        sb.append("FecProcesca: ").append(getFecProcesca()).append(", ");
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("QnuTotregis: ").append(getQnuTotregis()).append(", ");
        sb.append("QtyTotimp: ").append(getQtyTotimp()).append(", ");
        sb.append("XsnFormpago: ").append(getXsnFormpago()).append(", ");
        sb.append("XsnMedcreac: ").append(getXsnMedcreac()).append(", ");
        sb.append("XsnModcreac: ").append(getXsnModcreac()).append(", ");
        sb.append("XsnMultirem: ").append(getXsnMultirem());
        return sb.toString();
    }

	/** The entity manager. */
	@PersistenceContext(unitName="persistenceUnitTLBH")
    transient EntityManager entityManager;

	/** The id. */
	@EmbeddedId
    private TtlsbcabPK id;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public TtlsbcabPK getId() {
        return this.id;
    }

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(TtlsbcabPK id) {
        this.id = id;
    }

	/**
	 * Persist.
	 */
	@Transactional(value="tlbh")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	/**
	 * Removes the.
	 */
	@Transactional(value="tlbh")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Ttlsbcab attached = Ttlsbcab.findTtlsbcab(this.id);
            this.entityManager.remove(attached);
        }
    }

	/**
	 * Flush.
	 */
	@Transactional(value="tlbh")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	/**
	 * Clear.
	 */
	@Transactional(value="tlbh")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	/**
	 * Merge.
	 *
	 * @return the ttlsbcab
	 */
	@Transactional(value="tlbh")
    public Ttlsbcab merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Ttlsbcab merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	/**
	 * Entity manager.
	 *
	 * @return the entity manager
	 */
	public static final EntityManager entityManager() {
        EntityManager em = new Ttlsbcab().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	
	/**
	 * Count ttlsbcabs.
	 *
	 * @return the long
	 */
	@Transactional(value="tlbh")
	public static long countTtlsbcabs() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Ttlsbcab o", Long.class).getSingleResult();
    }

	
	/**
	 * Find all ttlsbcabs.
	 *
	 * @return the list
	 */
	@Transactional(value="tlbh")
	public static List<Ttlsbcab> findAllTtlsbcabs() {
        return entityManager().createQuery("SELECT o FROM Ttlsbcab o", Ttlsbcab.class).getResultList();
    }

	/**
	 * Find ttlsbcab.
	 *
	 * @param id the id
	 * @return the ttlsbcab
	 */
	public static Ttlsbcab findTtlsbcab(TtlsbcabPK id) {
        if (id == null) return null;
        return entityManager().find(Ttlsbcab.class, id);
    }

	
	/**
	 * Find ttlsbcab entries.
	 *
	 * @param firstResult the first result
	 * @param maxResults the max results
	 * @return the list
	 */
	@Transactional(value="tlbh")
	public static List<Ttlsbcab> findTtlsbcabEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Ttlsbcab o", Ttlsbcab.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }
}
